package com.example.logindb.sevices;

import com.example.logindb.entity.Feedback;
import com.example.logindb.entity.Help;
import com.example.logindb.repository.FeedbackRepository;
import com.example.logindb.repository.HelpRepository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FeedbackServiceImpl implements FeedbackService {
    private FeedbackRepository feedbackRepository;

    public FeedbackServiceImpl(FeedbackRepository feedbackRepository) {
        this.feedbackRepository = feedbackRepository;
    }

    @Override
    public void save(Feedback feedback) {
        feedbackRepository.save(feedback);
    }

    @Override
    public List<Feedback> getfeedback1() {
        return feedbackRepository.findRecentFeedbacks(0);
    }

    @Override
    public List<Feedback> getfeedback2() {
        return feedbackRepository.findRecentFeedbacks2(0);
    }

    @Override
    public void done(int id) {
        Feedback feedbak = feedbackRepository.findAllByFid(id);
        feedbak.setStatus(1);
        feedbackRepository.save(feedbak);
    }
}